{% extends "share_base.html" %}
{% load static %}
{# 加载自定义过滤器 #}
{#{% load custom_filters %}#}

{% block title %}
    分享
{% endblock %}


{% block head %}
    <link rel="stylesheet" type="text/css" href="{% static 'buckets/bucket.css' %}">
{% endblock %}

{% block boby %}
    {#    <div id="id-share-base" data-sharebase="{{ share_base }}" data-sharecode="{{ share_code }}"></div>#}
    {#    <div class="container-fluid" id="content-display-div"></div>#}

    <div class="container">
        <div class="row">
            <div class="offset-sm-4 col-sm-4">
                {% if tips_msg %}
                    <div>
                        <div class="alert alert-warning alert-dismissible" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                                    aria-hidden="true">&times;</span></button>
                            {{ tips_msg }}
                        </div>
                    </div>
                {% endif %}
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">{{ form_title }}</h3>
                    </div>
                    <div class="card-body">
                        <form method="POST" action="{{ action_url }}" enctype="multipart/form-data" id="myForm">
                            {% csrf_token %}
                            <div class="clearfix">
                                <p>文件：</p>
                                <p>&nbsp; &nbsp;{% if filepath %} {{ filepath }} {% endif %}</p>
                            </div>
                            {% for field in form %}
                                {% if field.is_hidden %}
                                    {{ field }}
                                {% else %}
                                    {{ field.label_tag }}{{ field }}
                                    <p class="text-danger">{{ field.errors.as_text }}</p>
                                {% endif %}
                            {% endfor %}
                            <p id="tip_text" class="text-danger float-left" style="font-size: 20px">
                                {% if ip_error %}{{ ip_error }}{% else %}
                                    {{ form.non_field_errors.as_text }}{% endif %}</p>

                            {% if not ip_error %}
                                <button type="submit" class="btn btn-primary float-left" id="myFormSubmit">{{ submit_text }}</button>
                            {% endif %}
                        </form>
                        {% block form_extend %}{% endblock %}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" src="{% static 'sweetalert2/dist/sweetalert2.all.min.js' %}"></script>
    {#    <!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support -->#}
    <script type="text/javascript" src="{% static 'promise-polyfill/dist/polyfill.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'art-template/template-web.js' %}"></script>
    <script type="text/javascript" src="{% static 'fontawesome-free/js/all.min.js' %}"></script>
    <script>
        document.getElementById('myForm').addEventListener('submit', function (event) {
            event.preventDefault();
            document.getElementById('myFormSubmit').disabled = true;
            document.getElementById('myFormSubmit').textContent = '等待下载';

            this.submit();
        });

        const url = new URL(window.location.href);
        const pValue = url.searchParams.get('p');

        setTimeout(document.getElementById('id_password').value = pValue, 1000);


    </script>

{% endblock %}
